package acn.spring.service;

import java.util.List;

import acn.spring.backend.ItemDao;
import acn.spring.domain.Item;

public class ItemServiceImpl implements ItemService {

	private ItemDao itemDao;
	
	public ItemServiceImpl() {
		System.out.println("ItemServiceImpl constructor...");
	}
	
	@Override
	public Item addItem(Item item) {
		Item persisted = itemDao.addItem(item);
		//throw new NullPointerException();
		return persisted;
	}
	
	@Override
	public List<Item> getAllItems() {
		return itemDao.getAllItems();
	}

	@Override
	public void setItemDao(ItemDao itemDao) {
		this.itemDao = itemDao;
	}

	@Override
	public Item getItemWithId(int id) {
		return itemDao.getItemWithId(id);
	}

	@Override
	public void deleteItem(int id) {
		itemDao.deleteItem(id);
	}
}
